<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<%@taglib prefix="code" tagdir="/WEB-INF/tags"%>
<script type="text/javascript" src="<c:url value="/script/ueditor/ueditor.config.js"/>"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="<c:url value="/script/ueditor/ueditor.all.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/script/ueditor/lang/zh-cn/zh-cn.js"/>"></script>
<link rel="stylesheet" type="text/css"  href="<c:url value="/script/ueditor/themes/default/css/ueditor.css"/>" />

<div style="margin:20px 0;"></div>
<div class="easyui-panel">
    <div style="padding:10px 60px 20px 60px">
        <form id="shareForm"  name="shareForm" method="post" action="<c:url value='/share/saveShareDetail.do'/>">
            <input type="hidden" id="share_uuid" name="share_uuid" value="${shareEntity.share_uuid}"/>
            <input type="hidden" id="ins_uuid" name="ins_uuid" value="${shareEntity.ins_uuid}"/>
            <input type="hidden" id="rec_id" name="rec_id" value="${shareEntity.rec_id}"/>
            <input type="hidden" id="publish_st" name="publish_st" value="${shareEntity.publish_st}"/>
            <table cellpadding="5" style="width:100%">
                <tr>
                    <td class="share_show">所属机构:</td>
                    <td class="share_show" colspan="3">
                        <input class="easyui-textbox"  data-options="required:true" type="text" readonly="readonly" id="inst_name" value="${shareEntity.inst_name}"/>
                        <a href="javascript:void(0)" class="easyui-linkbutton detail-remove" iconCls="icon-search" id="selelctBtn">选择</a>
                    </td>
                </tr>
                <tr>
                    <td class="share_show">分享类型:</td>
                    <td class="share_show" colspan="3"><code:codeSelect id="share_tp" name="share_tp" code_type="share_tp" showSelect="true" selectId="${shareEntity.share_tp}"></code:codeSelect></td>
                </tr>
                <tr>
                    <td class="share_show">标题:</td>
                    <td class="share_show"><input class="easyui-textbox" type="text" name="share_title" data-options="required:true,validType:['length[0,80]']" value="${shareEntity.share_title}"/></td>
                    <td class="share_4">发布时间:</td>
                    <td class="share_4"><input name="publish_date"  id="publish_date"  class="easyui-datetimebox" value="${shareEntity.publish_ts}"></td>
                </tr>
                <tr>
                    <td class="share_4">来源:</td>
                    <td class="share_4"><code:codeSelect id="share_source" name="share_source" code_type="share_source" showSelect="true" selectId="${shareEntity.share_source}"></code:codeSelect></td>
                    <td class="share_4">原文地址:</td>
                    <td class="share_4"><input class="easyui-textbox" type="text"  name="source_url" data-options="validType:['length[0,80]']" value="${shareEntity.source_url}" /></td>
                </tr>
                <tr>
                    <td class="share_2 share_3">摘要:</td>
                    <td class="share_2 share_3" colspan="3"><input class="easyui-textbox" type="text" style="height:100px;width:400px" name="share_desc" data-options="multiline:true,validType:['length[0,120]']" value="${shareEntity.share_desc}" /></td>
                </tr>
                <tr>
                    <td class="share_4">安卓缩略图:</td>
                    <td class="share_4"><div class="uploader uploader-file detail-remove" uploadType="0" affixType="6" storeType="1" affixIdx ="${shareEntity.share_uuid}"></div></td>
                    <td class="share_4">IOS缩略图:</td>
                    <td class="share_4"><div class="uploader uploader-file detail-remove" uploadType="0" affixType="6" storeType="3" affixIdx ="${shareEntity.share_uuid}"></div></td>
                </tr>
                <tr>
                    <td class="share_1 share_3">安卓引导图:</td>
                    <td class="share_1 share_3"><div class="uploader uploader-file detail-remove" uploadType="0" affixType="6" storeType="2" affixIdx ="${shareEntity.share_uuid}"></div></td>
                    <td class="share_1 share_3">IOS引导图:</td>
                    <td class="share_1 share_3"><div class="uploader uploader-file detail-remove" uploadType="0" affixType="6" storeType="4" affixIdx ="${shareEntity.share_uuid}"></div></td>
                </tr>
                <tr>
                    <td class="share_2 share_3 share_4">内容:</td>
                    <td class="share_2 share_3 share_4" colspan="3">
                        <div style="width:70%" >
                            <script id="editor"  name="share_content" type="text/plain">${shareEntity.share_content}</script>
                        </div>
                    </td>
                </tr>
            </table>
            <div style="text-align:center;padding:5px">
                <a href="javascript:void(0)" class="easyui-linkbutton btn detail-remove" iconCls="icon-save" onclick="submitForm()">保存</a>
                <a href="javascript:void(0)" class="easyui-linkbutton btn" iconCls="icon-back" onclick="back()">返回</a>
            </div>
        </form>
    </div>
</div>

<div id="menuTree">
    <div id="ztreeObj" class="ztree"></div>
</div>
<script>
    var ztreeObj;
    /*选择按钮*/
    $("#selelctBtn").click(function(){
        ztreeObj = showAppTree(selected, $("#ins_uuid").val());
    });

    /*确定按钮回调*/
    function selected(){
        var nodes = ztreeObj.getSelectedNodes();
        console.log(nodes);
        if(nodes && nodes.length > 0){
            $("#inst_name").textbox("setValue", nodes[0].NAME);
            $("#ins_uuid").val(nodes[0].ID);
        }
    }
    function showAppTree(confirmCallback, uuid, option){
        var options = {
            url: "../organization/getAppInfTree.do",
            title: "选择机构",
            confirmCallback: confirmCallback,
            openIds: uuid,
            showSearch: true,
            searchTitle: "机构代码/名称"
        };
        options = $.extend({}, options, option);
        return showTree(options);
    }
    function showTree(options){
        var jpTree = $().jpTree(options);
        return jpTree;
    }
    
    $("#share_tp").combobox({
    	onSelect: function(record){
    		if(!record || !record.id){
        		return;
        	}
        	$("td[class!='share_" + record.id + "']").css("display", "none");
        	$(".share_" + record.id).css("display", "");
        	$(".share_show").css("display", "");
    	}
    });

    $(function() {
        var publishDate = $('#publish_date').val();
        if(publishDate != null && publishDate != undefined){
            $("#publish_date").datetimebox("setValue", '${nowDate}');
        }
    });

    var ue = UE.getEditor('editor');
    //表单提交
    function submitForm(){
        //设置内容
        var html = ue.getContent();
        $("#editor").val(html);
        //提交
        $("#shareForm").submit();
    }
</script>